Skip to main content

Miniapp initialization

AppBoxoWebAppInit

An event to notify host app about miniapp’s initialization

AppBoxoWebAppGetInitData

Gets init data from host app Returns an object with:
  • app_id Miniapp ID
  • client_id Host client ID
  • payload String consisting of encrypted user details
  • data {[key: string]: any} null custom data passed from Hostapp
  • token optional User session token if it is still active
TIP There is a shortcut .getInitData() that handles saving details above in cookies or localStorage and returns a Promise.

Miniapp manipulation

AppBoxoWebAppOpenMiniApp

Opens other miniapp based on provided application ID Parameters
  • app_id required Miniapp ID to open

AppBoxoWebAppCloseMiniApp

Close current active miniapp

AppBoxoWebAppOnRestore

Event that is fired when miniapp is restored. Example:

Authentication

AppBoxoWebAppLogin

Login user using credentials given from host app Example:
TIP There is a shortcut that you can use:

AppBoxoWebAppLogout

Logout and clear session token Example:
TIP There is a shortcut that you can use:

AppBoxoWebAppClearToken

Clears saved token in host app

AppBoxoWebAppSaveToken

Saves provided token in host app Parameters
  • token required Token to save in host app

Appboxo Pay

WARNING This event is available from version 1.3.13 and above

AppBoxoWebAppPay

Send payment event to host app orderPaymentId:string, amount: number, orderId: string, currency: string, extraParams?: any Parameters
  • orderPaymentId required string Order payment identifier
  • miniappOrderId required number Unique identifier for the current payment
  • amount required boolean Payment amount
  • currency required string Define currency code
  • extraParams : any Any extra data
Example:
To receive the result of the payment event, just subscribe to the same event. Host app will sending these as the response: Parameters
  • orderPaymentId : string Order payment identifier
  • miniappOrderId: number Unique identifier for the current payment
  • hostappOrderId : number Unique identifier from hostapp
  • amount : boolean Payment amount
  • currency : string Define currency code
  • status : string Status of the payment
  • extraParams : any Any extra data
Example:

Tab bar

AppBoxoWebAppSetTabBar

Initialized native tab bar component Parameters
  • show required boolean Defines TabBar visibility
  • activeTab required number Active TabBar item id
  • list required Array<{ tabId: number, tabName: string, tabIcon: string }> Define tabs
  • options required { color: string, background: string, selectedColor: string, hasBorder: boolean, borderColor: string } Tab bar options
  • badges optional Array<{ tabId: number, background: string, color: string, value?: string }> Define tab item badges.
Example:
Sending event with only required changes will preserve initial options:

AppBoxoWebAppTabBarItemClick

Event that should be subscribed to in order to get active tab item click Example:

AppBoxoWebAppSetNavigationBar

Activates native navigation bar. Example:
Sending event with only required changes will preserve initial options:

Action buttons

AppBoxoWebAppSetActionButton

Changes actions button theme. By default it is dark. Example:

Loading indicator

AppBoxoWebAppLoadingIndicator

Show native loading indicator. Important: Loading indicator will timeout after 30 seconds with prompt to hide it if no event is dispatched to change it. Example:

QR code reader

AppBoxoWebAppOpenQRCodeReader

Opens native QR code reader. This method will prompt a permission request for camera. Example:
Results from QR code reader are received by events: AppBoxoWebAppOpenQRCodeReaderResult or AppBoxoWebAppOpenQRCodeReaderFailed Example:

Haptic feedback

AppBoxoWebAppVibrate

Triggers haptic engine on the device, if available. Parameters
  • style optional 'light' | 'medium' | 'heavy' Controls strength of vibration, defaults to ‘light’. Example:

Action sheet

AppBoxoWebAppShowActionSheet

Shows native action sheet Parameters header optional string Action sheet header text list required Array<{ id: number, text: string, role?: 'cancel' | 'destructive' | 'selected' }> Define action sheet items Example:

AppBoxoWebAppActionSheetItemClick

Event that should be subscribed to in order to get action sheet item click Example:

Geolocation

AppBoxoWebAppGetGeodata

Requests user geodata. This method will prompt a permission request to access geolocation. Example:

Map

AppBoxoWebAppChooseLocation

Open full screen map to choose location This method will prompt a permission request to access geolocation. Example:

AppBoxoWebAppOpenLocation

Open full screen map to that shows markered location This method will prompt a permission request to access geolocation. Example:

Alert

AppBoxoWebAppShowAlert

Show native alert box Parameters header optional string Alert header text message optional string Alert message buttons required Array<{ id: number, text: string, role?: 'cancel' | 'destructive' }> Define buttons Example:

AppBoxoWebAppShowImages

Open full screen native image gallery Parameters start_index optional number Index to start showing from images required Array<string> Image urls Example:
After image gallery is closed, same event will be dispatched back to miniapp with result data. Example:

Storage

AppBoxoWebAppStorageGet

Requests a value from the storage Parameters keys required Array<string> Keys for getting ([a-zA-Z_-0-9]) Example:

AppBoxoWebAppStorageGetKeys

Request list of keys of some stored values Parameters count required number Count of keys to get. Max value is 1000 offset optional number The offset required to fetch a specific subset of keys. Default: 0 Example:

AppBoxoWebAppStorageSet

Stores value in storage Parameters key required string The key of value ([a-zA-Z_-0-9]) value optional string value Example:

AppBoxoWebAppStorageRemove

Removes value in storage Parameters key required string The key of value ([a-zA-Z_-0-9]) Example:

AppBoxoWebAppStorageClear

Clears all data in storage Example:

Clipboard

AppBoxoWebAppGetClipboard

Gets the content on the system clipboard. Example:

AppBoxoWebAppSetClipboard

Sets the content on the system clipboard. Parameters data required string Content to be copied to clipboard Example:

System information

AppBoxoWebAppGetSystemInfo

Gets system information. Example:

Accelerometer

AppBoxoWebAppStartAccelerometer

Starts listening on acceleration data. Example:

AppBoxoWebAppStopAccelerometer

Stops listening on acceleration data. Example:

AppBoxoWebAppOnAccelerometerChange

Listens on the acceleration data event. You can send AppBoxoWebAppStopAccelerometer event to stop listening. Example:

Gyroscope

AppBoxoWebAppStartGyroscope

Starts listening on gyroscope data. Example:

AppBoxoWebAppStopGyroscope

Stops listening on gyroscope data. Example:

AppBoxoWebAppOnGyroscopeChange

Listens on the gyroscope data event. You can send AppBoxoWebAppStopGyroscope event to stop listening. Example:

Compass

AppBoxoWebAppStartCompass

Starts listening on compass data. Example:

AppBoxoWebAppStopCompass

Stops listening on compass data. Example:

AppBoxoWebAppOnCompassChange

Listens on the compass data event. You can send AppBoxoWebAppStopCompass event to stop listening. Example:

Background color

AppBoxoWebAppSetBackgroundColor

Dynamically sets the background color of the window.

Status bar color

AppBoxoWebAppSetStatusBarColor

Dynamically sets the status bar color

Tracking

AppBoxoWebAppTrack

Send postback tracking data about transaction Example:
TIP There is a shortcut that you can use to send tracking data:

Custom events

AppBoxoWebAppCustomEvent

Send custom event to host app. Example:

Download file

AppBoxoWebAppDownloadFile

Send event to download file Example:

Share text and file

AppBoxoWebAppShare

Send event to open native share modal Example: